/*
 * @Descripttion: 护士获取入库的一些信息，以辅助入库
 * @version: 1.0
 * @Author: 自由如风
 * @Date: 2021-05-07 15:02:03
 * @LastEditors: 自由如风
 * @LastEditTime: 2021-05-07 15:11:36
 */

const DB = require('../../lib/DB')
const { Success, Fail } = require('../../lib/Response')

module.exports = async function (ctx, next) {
    try {
        // 药品类别
        const sort_list = (await DB.models.drug_sort.findAll({
            attributes: ['sort_name', 'id']
        })).map(e => e.toJSON())
        // 药品剂量
        const dose_list = (await DB.models.dose.findAll({
            attributes: ['dose_name', 'id']
        }))
        // 厂家信息
        const medicine_enterprise_list = (await DB.models.medicine_enterprise.findAll({
            attributes: ['enterprise_name', 'id']
        }))

        ctx.body = new Success({
            sort_list,
            dose_list,
            medicine_enterprise_list,
        })
        await next();
    } catch (e) {
        ctx.body = new Fail(e.message)
    }
}